<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>用户系统-sso</title>
    <link href="/css/login.css" rel="stylesheet">
    <link href="https://cdn.bootcss.com/twitter-bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="wrapper fadeInDown">
    <div id="formContent">
        <!-- Tabs Titles -->

        <!-- Icon -->
        <div class="fadeIn first">
            <h3>用户系统登陆-SSO</h3>
        </div>

        <!-- Login Form -->
        <form onsubmit="return false;">
            <input type="text" id="username" class="fadeIn second" name="username" placeholder="login"/>
            <input type="password" id="password" class="fadeIn third" name="password" placeholder="password"/>
            <input id="login" type="submit" class="fadeIn fourth" value="Log In">
        </form>

        <!-- Remind Passowrd -->
        <div id="formFooter">
            <a class="underlineHover" href="#">Forgot Password?</a>
        </div>
    </div>
</div>
<script>
    $('#login').click(function () {
        var username = $('#username').val()
        var password = $('#password').val()
        if (username == '') {
            alert('请输入账号！')
            return
        }

        if (password == '') {
            alert('请输入密码！')
            return
        }

        $.ajax({
            url: '/user/toLogin',
            type: 'post',
            data: {'username': username, 'password': password},
            success(data) {
                if (data != 'success') {
                    alert(data)
                } else {
                    window.location.href = '/'
                }
            }
        })
    })
</script>
</body>
</html>
